'use strict';

const Controller = require('../../core/common');

class AddressesController extends Controller {

  async index() {
    const { ctx } = this;

    const data = await ctx.service.v1.addresses.findAll();

    this.success(data);

  }

  async show() {
    const { ctx } = this;

    const data = await ctx.service.v1.addresses.findAll();

    this.success(data);
  }

  async create() {
    const { ctx } = this;

    const { userId, ...defaults } = ctx.request.body;

    const data = await ctx.service.v1.addresses.create({ where: { userId } }, { defaults });

    this.success(data);
  }

}

module.exports = AddressesController;